<?php
require_once dirname(__FILE__).DIRECTORY_SEPARATOR.'../../model/Util/Tool.php';
header('Cache-control: private'); // IE 6 FIX

if(isset($_GET[0][0]) && !Tool::isEmpty($_GET[0][0]))
{
$lang = $_GET[0][0];

// register the session and set the cookie

$_SESSION['lang'] = $lang;

setcookie('lang', $lang, time() + (3600 * 24 * 30));
}
else if(isSet($_SESSION['lang']))
{
$lang = $_SESSION['lang'];
}
else if(isSet($_COOKIE['lang']))
{
$lang = $_COOKIE['lang'];
}
else
{
$lang = 'en';
}

switch ($lang) {
  case 'en':
  $lang_file = 'lang.en.php';
  break;

  case 'de':
  $lang_file = 'lang.de.php';
  break;

  case 'es':
  $lang_file = 'lang.es.php';
  break;
  
  case 'vi':
  $lang_file = 'lang.vi.php';
  break;

  default:
  $lang_file = 'lang.en.php';

}
require dirname(__FILE__).DIRECTORY_SEPARATOR.'../../languages/'.$lang_file;
?>